<?php
namespace Home\Controller;
use Think\Controller;
class AccountController extends CommonController {
    public function index(){
        $condition['user_id'] = $_SESSION['seller']['user_id'];
        $cond['condition'] = $condition;
        $con = array(
            'conditon' => $condition ,
            'order' => 'start_time desc'
        );
        $count = D('account')->getAccountList($con);
        $page = I('p') ? I('p') : '1';
        $pageSize = I('pageSize') ? I('pageSize') : '15';
        $condition['user_id'] = $_SESSION['seller']['user_id'];
        $cond['condition'] = $condition;
        $cond = array(
            'conditon' => $condition ,
            'page' => $page.','.$pageSize,
            'order' => 'start_time desc'
        );
        $res = D('account')->getAccountList($cond);
        $this->assign('account',$res);
        $Page       = new \Think\Page(count($count),$pageSize);// 实例化分页类 传入总记录数和每页显示的记录数
        $Page->setConfig('header','条留言');

        $Page->setConfig('first','首页');

        $Page->setConfig('prev','上一页');

        $Page->setConfig('next','下一页');

        $Page->setConfig('last','尾页');

        $Page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%<p id="pageTips">第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pageSize.' 条/页 共 %TOTAL_ROW% 条信息)</p>');
        $show       = $Page->show();// 分页显示输出
        $this->assign('page',$show);// 赋值分页输出
    	$this->display();
    }

    public function changeAccount(){
        $res = D('account')->editAccountInfo(array('account_id'=>$_POST['id']),array('recommend_state'=>$_POST['recommend_state']));
        if($res === false){
            $return_array = array(
                'code' => '10010',
                'msg' => '修改状态失败'
            );
            echo json_encode($return_array);
        }else{
            $return_array = array(
                'code' => '10000',
                'msg' => '修改状态成功'
            );
            echo json_encode($return_array);
        }
    }

}